<!--
 * @Author: your name
 * @Date: 2020-12-17 17:18:28
 * @LastEditTime: 2020-12-17 20:01:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\warranty\extendedManagement\importModal.vue
-->
<template>
    <div>
        <el-dialog
                :title="$t('export')"
        :visible="newVisibleRemark"
        class="el-dialog-lg"
        @close="()=>{$store.commit('setNewVisibleRemark',false)}" width="35%"
        :close-on-click-modal='false'
        >
            <el-form ref="form" :model="form" label-width="150px" >
                <el-row :gutter="24">
                    <el-col :span="20" :offset="1">
                        <el-form-item :label="$t('devWifi.useStatus')" prop="status" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                            <el-select v-model="form.status" filterable :placeholder="$t('index.selectStates')" clearable >
                                <el-option
                                    v-for="item in statusList"
                                    :key="item.text"
                                    :label="item.text"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item :label="$t('index.timeHorizon')" prop="EndTime" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                            <el-date-picker
                            v-model="form.StartTime"
                            type="date"
                            :placeholder="$t('selectDate')"
                            value-format='yyyy-MM-dd'
                            :clearable='true'
                            :picker-options="pickerOptions"
                            style="width:47%;"
                            >
                            </el-date-picker>
                            -
                            <el-date-picker
                            v-model="form.EndTime"
                            type="date"
                            :placeholder="$t('selectDate')"
                            value-format='yyyy-MM-dd'
                            :clearable='true'
                            :picker-options="pickerOptions"
                            style="width:47%;"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="()=>{$store.commit('setNewVisibleRemark',false)}">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="save('form')">{{$t('save')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import fileInput from '../../../components/common/baseFileInput'
export default {
    components: {
        fileInput
    },
    props: {

    },
    data() {
        return {
            form:{
                status:'',
                StartTime:'',
                EndTime:'',
            },
            statusList:[{
                id:'0',
                text: this.$t('device.inverter.js_free')
            },{
                id:'1',
                text:this.$t('sn.js_used')
            }],
            pickerOptions:{ //禁用今天之后的时间
                disabledDate(time) {
                    return time.getTime() > Date.now()
                }
            },
        };
    },
    computed: {
        newVisibleRemark(){
            return this.$store.state.sysStore.newVisibleRemark
        }
    },
    watch: {

    },
    created() {

    },
    mounted() {

    },
    methods: {
        delayCodeImportDelayCode(){
            this.comm.windowOpen('/salecode/exportCode',{
                status:this.form.status,
                startTime:this.form.StartTime,
                endTime:this.form.EndTime,
            })
            this.$store.commit('setNewVisibleRemark',false)
        },
        save(formName){
            this.$refs[formName].validate((valid) => {
              if (valid) {
                  this.delayCodeImportDelayCode()
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less" scoped>

</style>
